<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@page language="java" import="com.ray.util.WeiXinUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>微信分享测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style type="text/css">
html {
	-ms-text-size-adjust: 100%;
	-webkit-text-size-adjust: 100%;
	-webkit-user-select: none;
	user-select: none;
}

body {
	line-height: 1.6;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	background-color: #f1f0f6;
}

* {
	margin: 0;
	padding: 0;
}

button {
	font-family: inherit;
	font-size: 100%;
	margin: 0;
	*font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

ul, ol {
	padding-left: 0;
	list-style-type: none;
}

a {
	text-decoration: none;
}

.label_box {
	background-color: #ffffff;
}

.label_item {
	padding-left: 15px;
}

.label_inner {
	padding-top: 10px;
	padding-bottom: 10px;
	min-height: 24px;
	position: relative;
}

.label_inner:before {
	content: " ";
	position: absolute;
	left: 0;
	top: 0;
	width: 200%;
	height: 1px;
	border-top: 1px solid #ededed;
	-webkit-transform-origin: 0 0;
	transform-origin: 0 0;
	-webkit-transform: scale(0.5);
	transform: scale(0.5);
	top: auto;
	bottom: -2px;
}

.lbox_close {
	position: relative;
}

.lbox_close:before {
	content: " ";
	position: absolute;
	left: 0;
	top: 0;
	width: 200%;
	height: 1px;
	border-top: 1px solid #ededed;
	-webkit-transform-origin: 0 0;
	transform-origin: 0 0;
	-webkit-transform: scale(0.5);
	transform: scale(0.5);
}

.lbox_close:after {
	content: " ";
	position: absolute;
	left: 0;
	top: 0;
	width: 200%;
	height: 1px;
	border-top: 1px solid #ededed;
	-webkit-transform-origin: 0 0;
	transform-origin: 0 0;
	-webkit-transform: scale(0.5);
	transform: scale(0.5);
	top: auto;
	bottom: -2px;
}

.lbox_close .label_item:last-child .label_inner:before {
	display: none;
}

.btn {
	display: block;
	margin-left: auto;
	margin-right: auto;
	padding-left: 14px;
	padding-right: 14px;
	font-size: 18px;
	text-align: center;
	text-decoration: none;
	overflow: visible;
	/*.btn_h(@btnHeight);*/
	height: 42px;
	border-radius: 5px;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	color: #ffffff;
	line-height: 42px;
	-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}

.btn.btn_inline {
	display: inline-block;
}

.btn_primary {
	background-color: #437DBA;
}

.btn_primary:not (.btn_disabled ):visited {
	color: #ffffff;
}

.btn_primary:not (.btn_disabled ):active {
	color: rgba(255, 255, 255, 0.9);
	background-color: #3b78b9;
}

button.btn {
	width: 100%;
	border: 0;
	outline: 0;
	-webkit-appearance: none;
}

button.btn:focus {
	outline: 0;
}

.wxapi_container {
	font-size: 16px;
}

h1 {
	font-size: 14px;
	font-weight: 400;
	line-height: 2em;
	padding-left: 15px;
	color: #8d8c92;
}

.desc {
	font-size: 14px;
	font-weight: 400;
	line-height: 2em;
	color: #8d8c92;
}

.wxapi_index_item a {
	display: block;
	color: #3e3e3e;
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.wxapi_form {
	background-color: #ffffff;
	padding: 0 15px;
	margin-top: 30px;
	padding-bottom: 15px;
}

h3 {
	padding-top: 16px;
	margin-top: 25px;
	font-size: 16px;
	font-weight: 400;
	color: #3e3e3e;
	position: relative;
}

h3:first-child {
	padding-top: 15px;
}

h3:before {
	content: " ";
	position: absolute;
	left: 0;
	top: 0;
	width: 200%;
	height: 1px;
	border-top: 1px solid #ededed;
	-webkit-transform-origin: 0 0;
	transform-origin: 0 0;
	-webkit-transform: scale(0.5);
	transform: scale(0.5);
}

.btn {
	margin-bottom: 15px;
}
</style>

<script src="/js/jquery.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
</head>
<body>
	<%
		Map<String, Object> res = new HashMap<String, Object>();
		res = WeiXinUtil.getWxConfig(request);
		request.setAttribute("appId", res.get("appId"));
		request.setAttribute("timestamp", res.get("timestamp"));
		request.setAttribute("nonceStr", res.get("nonceStr"));
		request.setAttribute("signature", res.get("signature"));
		
		
		System.out.println(res.get("nonceStr"));
		System.out.println(res.get("signature"));
	%>

<body>
	<div class="wxapi_container">
		<div class="wxapi_index_container">
			<ul class="label_box lbox_close wxapi_index_list">
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-basic">基础接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-share">分享接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-image">图像接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-voice">音频接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-device">设备信息接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-location">地理位置接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-webview">界面操作接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-scan">微信扫一扫接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-enterprise">通讯录接口</a></li>
				<li class="label_item wxapi_index_item"><a class="label_inner"
					href="http://work.weixin.qq.com/api/jsapidemo#menu-previewfile">文件预览</a></li>
			</ul>
		</div>
		<div class="lbox_close wxapi_form">
			<h3 id="menu-basic">基础接口</h3>
			<span class="desc">判断当前客户端是否支持指定JS接口</span>
			<button class="btn btn_primary" id="checkJsApi">checkJsApi</button>
			<h3 id="menu-share">分享接口</h3>
			<span class="desc">获取“转发”按钮点击状态及自定义分享内容接口</span>
			<button class="btn btn_primary" id="onMenuShareAppMessage">onMenuShareAppMessage</button>
			<span class="desc">获取“微信”按钮点击状态及自定义分享内容接口</span>
			<button class="btn btn_primary" id="onMenuShareWechat">onMenuShareWechat</button>
			<h3 id="menu-image">图像接口</h3>
			<span class="desc">拍照或从手机相册中选图接口</span>
			<button class="btn btn_primary" id="chooseImage">chooseImage</button>
			<span class="desc">预览图片接口</span>
			<button class="btn btn_primary" id="previewImage">previewImage</button>
			<span class="desc">上传图片接口</span>
			<button class="btn btn_primary" id="uploadImage">uploadImage</button>
			<span class="desc">下载图片接口</span>
			<button class="btn btn_primary" id="downloadImage">downloadImage</button>
			<h3 id="menu-voice">音频接口</h3>
			<span class="desc">开始录音接口</span>
			<button class="btn btn_primary" id="startRecord">startRecord</button>
			<span class="desc">停止录音接口</span>
			<button class="btn btn_primary" id="stopRecord">stopRecord</button>
			<span class="desc">播放语音接口</span>
			<button class="btn btn_primary" id="playVoice">playVoice</button>
			<span class="desc">暂停播放接口</span>
			<button class="btn btn_primary" id="pauseVoice">pauseVoice</button>
			<span class="desc">停止播放接口</span>
			<button class="btn btn_primary" id="stopVoice">stopVoice</button>
			<span class="desc">上传语音接口</span>
			<button class="btn btn_primary" id="uploadVoice">uploadVoice</button>
			<span class="desc">下载语音接口</span>
			<button class="btn btn_primary" id="downloadVoice">downloadVoice</button>
			<h3 id="menu-device">设备信息接口</h3>
			<span class="desc">获取网络状态接口</span>
			<button class="btn btn_primary" id="getNetworkType">getNetworkType</button>
			<h3 id="menu-location">地理位置接口</h3>
			<span class="desc">使用企业微信内置地图查看位置接口</span>
			<button class="btn btn_primary" id="openLocation">openLocation</button>
			<span class="desc">获取地理位置接口</span>
			<button class="btn btn_primary" id="getLocation">getLocation</button>
			<h3 id="menu-webview">界面操作接口</h3>
			<span class="desc">隐藏右上角菜单接口</span>
			<button class="btn btn_primary" id="hideOptionMenu">hideOptionMenu</button>
			<span class="desc">显示右上角菜单接口</span>
			<button class="btn btn_primary" id="showOptionMenu">showOptionMenu</button>
			<span class="desc">关闭当前网页窗口接口</span>
			<button class="btn btn_primary" id="closeWindow">closeWindow</button>
			<span class="desc">批量隐藏功能按钮接口</span>
			<button class="btn btn_primary" id="hideMenuItems">hideMenuItems</button>
			<span class="desc">批量显示功能按钮接口</span>
			<button class="btn btn_primary" id="showMenuItems">showMenuItems</button>
			<span class="desc">隐藏所有非基础按钮接口</span>
			<button class="btn btn_primary" id="hideAllNonBaseMenuItem">hideAllNonBaseMenuItem</button>
			<span class="desc">显示所有功能按钮接口</span>
			<button class="btn btn_primary" id="showAllNonBaseMenuItem">showAllNonBaseMenuItem</button>
			<h3 id="menu-scan">企业微信扫一扫</h3>
			<span class="desc">调起微信扫一扫接口</span>
			<button class="btn btn_primary" id="scanQRCode0">scanQRCode(企业微信处理结果)</button>
			<button class="btn btn_primary" id="scanQRCode1">scanQRCode(直接返回结果)</button>
			<h3 id="menu-enterprise">通讯录接口</h3>
			<span class="desc">通讯录选人接口</span>
			<button class="btn btn_primary" id="selectEnterpriseContact">selectEnterpriseContact</button>
			<h3 id="menu-previewfile">文件接口</h3>
			<span class="desc">文件预览接口</span>
			<button class="btn btn_primary" id="previewFile">previewFile</button>
		</div>
	</div>

	<script>
		/*
		 * 注意：
		 * 所有的JS接口只能在应用配置的安全域名下面使用。   
		 *
		 */
		wx.config({
			beta : true,
			debug : true,
			appId : '${appId}',
			timestamp : '${timestamp}',
			nonceStr : '${nonceStr }',
			signature : '${signature}',
			jsApiList : [ 'checkJsApi', 'onMenuShareAppMessage',
					'onMenuShareWechat', 'startRecord', 'stopRecord',
					'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice',
					'uploadVoice', 'downloadVoice', 'chooseImage',
					'previewImage', 'uploadImage', 'downloadImage',
					'getNetworkType', 'openLocation', 'getLocation',
					'hideOptionMenu', 'showOptionMenu', 'hideMenuItems',
					'showMenuItems', 'hideAllNonBaseMenuItem',
					'showAllNonBaseMenuItem', 'closeWindow', 'scanQRCode',
					'previewFile', 'openEnterpriseChat',
					'selectEnterpriseContact' ]
		});

		//通过ready接口处理成功验证
		wx.ready(function() {
			// config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
		
		});
		
		// 1 判断当前版本是否支持指定 JS 接口，支持批量判断
		  document.querySelector('#checkJsApi').onclick = function () {
		    wx.checkJsApi({
		      jsApiList: [
		        'getNetworkType',
		        'previewImage'
		      ],
		      success: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		  };

		  // 2. 分享接口
		  // 2.1 监听“分享给朋友”，按钮点击、自定义分享内容及分享结果接口
		  document.querySelector('#onMenuShareAppMessage').onclick = function () {
		    wx.onMenuShareAppMessage({
		      title: '微信分享给朋友测试',
		      desc: '哈哈哈哈哈',
		      link: 'http://uwxcgs.natappfree.cc/WeiXin_SanFenBaiXue/index.jsp',
		      imgUrl: 'http://uwxcgs.natappfree.cc/WeiXin_SanFenBaiXue/img/test1.jpg',
		      trigger: function (res) {
		        alert('用户点击发送给朋友');
		      },
		      success: function (res) {
		        alert('已分享');
		      },
		      cancel: function (res) {
		        alert('已取消');
		      },
		      fail: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		    alert('已注册获取“发送给朋友”状态事件');
		  };

		  // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
		  document.querySelector('#onMenuShareTimeline').onclick = function () {
		    wx.onMenuShareTimeline({
		      title: '互联网之子',
		      link: 'http://movie.douban.com/subject/25785114/',
		      imgUrl: 'http://img3.douban.com/view/movie_poster_cover/spst/public/p2166127561.jpg',
		      trigger: function (res) {
		        alert('用户点击分享到朋友圈');
		      },
		      success: function (res) {
		        alert('已分享');
		      },
		      cancel: function (res) {
		        alert('已取消');
		      },
		      fail: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		    alert('已注册获取“分享到朋友圈”状态事件');
		  };

		  // 2.3 监听“分享到QQ”按钮点击、自定义分享内容及分享结果接口
		  document.querySelector('#onMenuShareQQ').onclick = function () {
		    wx.onMenuShareQQ({
		      title: '互联网之子',
		      desc: '在长大的过程中，我才慢慢发现，我身边的所有事，别人跟我说的所有事，那些所谓本来如此，注定如此的事，它们其实没有非得如此，事情是可以改变的。更重要的是，有些事既然错了，那就该做出改变。',
		      link: 'http://movie.douban.com/subject/25785114/',
		      imgUrl: 'http://img3.douban.com/view/movie_poster_cover/spst/public/p2166127561.jpg',
		      trigger: function (res) {
		        alert('用户点击分享到QQ');
		      },
		      complete: function (res) {
		        alert(JSON.stringify(res));
		      },
		      success: function (res) {
		        alert('已分享');
		      },
		      cancel: function (res) {
		        alert('已取消');
		      },
		      fail: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		    alert('已注册获取“分享到 QQ”状态事件');
		  };
		  
		  // 2.4 监听“分享到微博”按钮点击、自定义分享内容及分享结果接口
		  document.querySelector('#onMenuShareWeibo').onclick = function () {
		    wx.onMenuShareWeibo({
		      title: '互联网之子',
		      desc: '在长大的过程中，我才慢慢发现，我身边的所有事，别人跟我说的所有事，那些所谓本来如此，注定如此的事，它们其实没有非得如此，事情是可以改变的。更重要的是，有些事既然错了，那就该做出改变。',
		      link: 'http://movie.douban.com/subject/25785114/',
		      imgUrl: 'http://img3.douban.com/view/movie_poster_cover/spst/public/p2166127561.jpg',
		      trigger: function (res) {
		        alert('用户点击分享到微博');
		      },
		      complete: function (res) {
		        alert(JSON.stringify(res));
		      },
		      success: function (res) {
		        alert('已分享');
		      },
		      cancel: function (res) {
		        alert('已取消');
		      },
		      fail: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		    alert('已注册获取“分享到微博”状态事件');
		  };

		  // 3 智能接口
		  var voice = {
		    localId: '',
		    serverId: ''
		  };
		  // 3.1 识别音频并返回识别结果
		  document.querySelector('#translateVoice').onclick = function () {
		    if (voice.localId == '') {
		      alert('请先使用 startRecord 接口录制一段声音');
		      return;
		    }
		    wx.translateVoice({
		      localId: voice.localId,
		      complete: function (res) {
		        if (res.hasOwnProperty('translateResult')) {
		          alert('识别结果：' + res.translateResult);
		        } else {
		          alert('无法识别');
		        }
		      }
		    });
		  };

		  // 4 音频接口
		  // 4.2 开始录音
		  document.querySelector('#startRecord').onclick = function () {
		    wx.startRecord({
		      cancel: function () {
		        alert('用户拒绝授权录音');
		      }
		    });
		  };

		  // 4.3 停止录音
		  document.querySelector('#stopRecord').onclick = function () {
		    wx.stopRecord({
		      success: function (res) {
		        voice.localId = res.localId;
		      },
		      fail: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		  };

		  // 4.4 监听录音自动停止
		  wx.onVoiceRecordEnd({
		    complete: function (res) {
		      voice.localId = res.localId;
		      alert('录音时间已超过一分钟');
		    }
		  });

		  // 4.5 播放音频
		  document.querySelector('#playVoice').onclick = function () {
		    if (voice.localId == '') {
		      alert('请先使用 startRecord 接口录制一段声音');
		      return;
		    }
		    wx.playVoice({
		      localId: voice.localId
		    });
		  };

		  // 4.6 暂停播放音频
		  document.querySelector('#pauseVoice').onclick = function () {
		    wx.pauseVoice({
		      localId: voice.localId
		    });
		  };

		  // 4.7 停止播放音频
		  document.querySelector('#stopVoice').onclick = function () {
		    wx.stopVoice({
		      localId: voice.localId
		    });
		  };

		  // 4.8 监听录音播放停止
		  wx.onVoicePlayEnd({
		    complete: function (res) {
		      alert('录音（' + res.localId + '）播放结束');
		    }
		  });

		  // 4.8 上传语音
		  document.querySelector('#uploadVoice').onclick = function () {
		    if (voice.localId == '') {
		      alert('请先使用 startRecord 接口录制一段声音');
		      return;
		    }
		    wx.uploadVoice({
		      localId: voice.localId,
		      success: function (res) {
		        alert('上传语音成功，serverId 为' + res.serverId);
		        voice.serverId = res.serverId;
		      }
		    });
		  };

		  // 4.9 下载语音
		  document.querySelector('#downloadVoice').onclick = function () {
		    if (voice.serverId == '') {
		      alert('请先使用 uploadVoice 上传声音');
		      return;
		    }
		    wx.downloadVoice({
		      serverId: voice.serverId,
		      success: function (res) {
		        alert('下载语音成功，localId 为' + res.localId);
		        voice.localId = res.localId;
		      }
		    });
		  };

		  // 5 图片接口
		  // 5.1 拍照、本地选图
		  var images = {
		    localId: [],
		    serverId: []
		  };
		  document.querySelector('#chooseImage').onclick = function () {
		    wx.chooseImage({
		      success: function (res) {
		        images.localId = res.localIds;
		        alert('已选择 ' + res.localIds.length + ' 张图片');
		      }
		    });
		  };

		  // 5.2 图片预览
		  document.querySelector('#previewImage').onclick = function () {
		    wx.previewImage({
		      current: 'http://img5.douban.com/view/photo/photo/public/p1353993776.jpg',
		      urls: [
		        'http://img3.douban.com/view/photo/photo/public/p2152117150.jpg',
		        'http://img5.douban.com/view/photo/photo/public/p1353993776.jpg',
		        'http://img3.douban.com/view/photo/photo/public/p2152134700.jpg'
		      ]
		    });
		  };

		  // 5.3 上传图片
		  document.querySelector('#uploadImage').onclick = function () {
		    if (images.localId.length == 0) {
		      alert('请先使用 chooseImage 接口选择图片');
		      return;
		    }
		    var i = 0, length = images.localId.length;
		    images.serverId = [];
		    function upload() {
		      wx.uploadImage({
		        localId: images.localId[i],
		        success: function (res) {
		          alert(JSON.stringify(res));
		          i++;
		          alert('已上传：' + i + '/' + length);
		          images.serverId.push(res.serverId);
		          if (i < length) {
		            upload();
		          }
		        },
		        fail: function (res) {
		          alert(JSON.stringify(res));
		        }
		      });
		    }
		    upload();
		  };

		  // 5.4 下载图片
		  document.querySelector('#downloadImage').onclick = function () {
		    if (images.serverId.length === 0) {
		      alert('请先使用 uploadImage 上传图片');
		      return;
		    }
		    var i = 0, length = images.serverId.length;
		    images.localId = [];
		    function download() {
		      wx.downloadImage({
		        serverId: images.serverId[i],
		        success: function (res) {
		          alert(JSON.stringify(res));
		          i++;
		          alert('已下载：' + i + '/' + length);
		          images.localId.push(res.localId);
		          if (i < length) {
		            download();
		          }
		        }
		      });
		    }
		    download();
		  };

		  // 6 设备信息接口
		  // 6.1 获取当前网络状态
		  document.querySelector('#getNetworkType').onclick = function () {
		    wx.getNetworkType({
		      success: function (res) {
		        alert(res.networkType);
		      },
		      fail: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		  };

		  // 7 地理位置接口
		  // 7.1 查看地理位置
		  document.querySelector('#openLocation').onclick = function () {
		    wx.openLocation({
		      latitude: 23.099994,
		      longitude: 113.324520,
		      name: 'TIT 创意园',
		      address: '广州市海珠区新港中路 397 号',
		      scale: 14,
		      infoUrl: 'http://weixin.qq.com'
		    });
		  };

		  // 7.2 获取当前地理位置
		  document.querySelector('#getLocation').onclick = function () {
		    wx.getLocation({
		      success: function (res) {
		        alert(JSON.stringify(res));
		      },
		      cancel: function (res) {
		        alert('用户拒绝授权获取地理位置');
		      }
		    });
		  };

		  // 8 界面操作接口
		  // 8.1 隐藏右上角菜单
		  document.querySelector('#hideOptionMenu').onclick = function () {
		    wx.hideOptionMenu();
		  };

		  // 8.2 显示右上角菜单
		  document.querySelector('#showOptionMenu').onclick = function () {
		    wx.showOptionMenu();
		  };

		  // 8.3 批量隐藏菜单项
		  document.querySelector('#hideMenuItems').onclick = function () {
		    wx.hideMenuItems({
		      menuList: [
		        'menuItem:readMode', // 阅读模式
		        'menuItem:share:timeline', // 分享到朋友圈
		        'menuItem:copyUrl' // 复制链接
		      ],
		      success: function (res) {
		        alert('已隐藏“阅读模式”，“分享到朋友圈”，“复制链接”等按钮');
		      },
		      fail: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		  };

		  // 8.4 批量显示菜单项
		  document.querySelector('#showMenuItems').onclick = function () {
		    wx.showMenuItems({
		      menuList: [
		        'menuItem:readMode', // 阅读模式
		        'menuItem:share:timeline', // 分享到朋友圈
		        'menuItem:copyUrl' // 复制链接
		      ],
		      success: function (res) {
		        alert('已显示“阅读模式”，“分享到朋友圈”，“复制链接”等按钮');
		      },
		      fail: function (res) {
		        alert(JSON.stringify(res));
		      }
		    });
		  };

		  // 8.5 隐藏所有非基本菜单项
		  document.querySelector('#hideAllNonBaseMenuItem').onclick = function () {
		    wx.hideAllNonBaseMenuItem({
		      success: function () {
		        alert('已隐藏所有非基本菜单项');
		      }
		    });
		  };

		  // 8.6 显示所有被隐藏的非基本菜单项
		  document.querySelector('#showAllNonBaseMenuItem').onclick = function () {
		    wx.showAllNonBaseMenuItem({
		      success: function () {
		        alert('已显示所有非基本菜单项');
		      }
		    });
		  };

		  // 8.7 关闭当前窗口
		  document.querySelector('#closeWindow').onclick = function () {
		    wx.closeWindow();
		  };

		  // 9 微信原生接口
		  // 9.1.1 扫描二维码并返回结果
		  document.querySelector('#scanQRCode0').onclick = function () {
		    wx.scanQRCode({
		      desc: 'scanQRCode desc'
		    });
		  };
		  // 9.1.2 扫描二维码并返回结果
		  document.querySelector('#scanQRCode1').onclick = function () {
		    wx.scanQRCode({
		      needResult: 1,
		      desc: 'scanQRCode desc',
		      success: function (res) {
		    	  
		        alert(JSON.stringify(res));
		      }
		    });
		  };

		  var shareData = typeof(shareData) === 'undefined' ? {
		    title: 'Javen 微信JSSDK测试',
		    desc: '微信JS-SDK,帮助第三方为用户提供更优质的移动web服务',
		    link: 'http://www.cnblogs.com/zyw-205520/',
		    imgUrl: 'http://g.hiphotos.baidu.com/imgad/pic/item/a8773912b31bb051be533b24317adab44aede043.jpg'
		  } : shareData;

		
	

		wx.error(function (res) {
		  alert(res.errMsg);
		});
		
		
	</script>


</body>
</html>